package com.wallace.downloadserver.bean

import com.sun.xml.internal.ws.developer.Serialization

@Serialization
class User {

    constructor(uid: String, name: String, sex: Int? = null, username: String? = null, password: String? = null,
                phoneNumber: String? = null, email: String? = null, idCard: String? = null, role: Int) {
        this.uid = uid
        this.name = name
        this.sex = sex
        this.username = username
        this.password = password
        this.phoneNumber = phoneNumber
        this.email = email
        this.idCard = idCard
        this.role = role
    }

    var uid: String = ""
        set(uid) {
            field = uid.trim { it <= ' ' }
        }
    var name: String = ""
        set(name) {
            field = name.trim { it <= ' ' }
        }
    var sex: Int? = null
    var username: String? = null
        set(username) {
            field = username?.trim { it <= ' ' }
        }
    var password: String? = null
        set(password) {
            field = password?.trim { it <= ' ' }
        }
    var phoneNumber: String? = null
        set(phoneNumber) {
            field = phoneNumber?.trim { it <= ' ' }
        }
    var email: String? = null
        set(email) {
            field = email?.trim { it <= ' ' }
        }
    var idCard: String? = null
        set(idCard) {
            field = idCard?.trim { it <= ' ' }
        }
    var role: Int = -1

    override fun toString(): String {
        return "User{" +
                "uid = $uid, " +
                "name = $name, " +
                "role = $role, " +
                "}"
    }

    companion object {
        private const val serialVersionUID = 1L
    }
}